<%- include header.ejs %>
<div >
    <div style="margin-left: 10%;margin-right: 10%;min-height: 300px">
        <div style="background-color: white;height: 50px">
            <div style="height: 50px;background-color: #8c0f13;width: 100px;text-align:center;margin-left: 50px;color: white;font-size: 18px;line-height: 50px">留言板</div>
        </div>
        <div style="float: left;width: 25%;margin-top: 30px;height: 250px;background-color: white;">
            <div style="height: 30px;background-color: #8a0e12;color: white;text-align: center;font-size: 18px">
                <span style="line-height: 30px">查询</span>
            </div>
            <form action="/message" method="get">
            <div style="font-size: 18px;margin: 25px">
                <span>姓名：<input style="width: 150px" type="text" name="name"></span><br>
                <span>留言：<input style="width: 150px" type="text" name="content"></span>

            </div>
            <div style="float: right;margin-right: 20px">
                <input type="submit" value="查询" class="btn btn-danger">
            </div>
            </form>
        </div>
        <div style="float: left;width: 70%;font-size: 14px;font-family: '微软雅黑'">

            <div style="margin-top: 30px;padding-left: 50px">
                <% results.forEach(function(data, index){ %>



                <div style="width:10%;float:left;font-size: 18px;margin-bottom:15px;">
                <span style="font-size: 14px">
                    <b style="color:#d11519 ">· &nbsp;&nbsp;</b><%= data.Message_PersonName %>
                    <!--&nbsp;&nbsp;&nbsp;&nbsp;<%= data.Message_MessageDateTime.split(' ')[0]%>-->
                </span>
                </div>
                <a href="/messageDetails?id=<%= data.Message_ID%>" style="color: #000000"><div style="height:20px;width:60%;float: left;margin-left: 50px"><%= data.Message_Content.length>30?data.Message_Content.substr(0,50)+'···':data.Message_Content%></div></a>
                <div style="float: left;margin-left: 50px"><% if(data.Message_State==1){%>未回复<%}else{%>已回复<%}%></div>

                <div style="clear: both"></div>
                <% }) %>
            </div>
            <div style="text-align: center;margin-top: 50px;height: 100px">
                <%if(page.totalPage!=0&&page.curPage<=page.totalPage){%>
                <b  style="margin-left: 20%;font-size: 13px;float:left;border-radius: 20px;border: solid <%if(page.curPage==1){%>#979797<%}else{%>#c8656f<%}%> 2px;width: 100px;padding: 2px"><a style="cursor: pointer;color:<%if(page.curPage==1){%>#979797"<%}else{%>#c8656f" onclick="forPage(-1)"<%}%>><上一页</a></b>
                <b  style="margin-left:40%;font-size: 13px;float:left;border-radius: 20px;border: solid <%if(page.curPage!=page.totalPage){%>#c8656f<%}else{%>#979797<%}%> 2px;width: 100px;padding: 2px"><a style="cursor: pointer;color:<%if(page.curPage!=page.totalPage){%>#c8656f" onclick="forPage(1)"<%}else{%>#979797"<%}%>>下一页></a></b>
                <%}else{%>
                <span style="font-size: 20px;line-height: 100px">没有找到相关数据</span>
                <%}%>
            </div>
            <form action="/addMessage" method="post">
                <div style="padding-top: 50px;padding-left: 50px;clear: both">
                    <h3>用户留言</h3>
                    <div style="width: 20%;float: left;font-size: 16px">
                        <p>姓名：</p>
                        <p style="margin-top: 20px">电子邮箱：</p>
                        <p style="margin-top: 20px">联系电话：</p>
                        <p style="margin-top: 20px">留言：</p>
                    </div>
                    <div style="width: 50%;float: left;">
                        <input type="text" name="name"><br>
                        <input type="email" name="email"><br>
                        <input type="text" name="phone"><br>
                        <textarea style="width: 100%;height: 100px" type="text" name="content"></textarea><br>
                    </div>
                    <div style="clear: both;padding-top: 30px">
                        <input style="float: right;margin-right: 30%" type="submit" value="提交" class="btn btn-success">
                    </div>
                </div>
            </form>
        </div>


    </div>
</div>


<%- include footer.ejs %>
<script>
    function forPage(num){
        var curPage=<%=page.curPage%>;
        var totalPage=<%=page.totalPage%>
        if(window.location.href.indexOf('&')<0){
            window.location.href=window.location.href.split('?')[0]+'?page='+(curPage+num)
        }else{
            window.location.href=window.location.href.split('&')[0]+'&'+window.location.href.split('&')[1]+'&page='+(curPage+num)
        }


    }
</script>